﻿//弹出蒙板层显示弹框
var mask = {
        title:null,
        show:function(id){
			$("#mask").remove();
			$("body").append("<div id='mask'></div>");
			var maskHeight=$("body").height();
			if (maskHeight<document.documentElement.clientHeight)
			{
				maskHeight = document.documentElement.clientHeight;
			}
			$("#mask").height(maskHeight);
			$("#mask").show();
			$("#"+id).show();
			moveit(id);
			$('<iframe id="alertIframe" style="position:absolute; z-dex:20;width:100%;height:100%;_filter:alpha(opacity=0);opacity=0;border-style:none;"></iframe>').appendTo("#mask");
        },
        hide:function(id){
			$("#mask").hide();
			$("#"+id).hide();
			$("#alertIframe").remove();
        }
}

function moveit(id)
{
	var marginleft = -($("#"+id).width()/2);
	var marginheight = -($("#"+id).height()/2);
	var top = ($(window).height())/2 + $(window).scrollTop();
	var left = ($(window).width())/2 + $(window).scrollLeft();
	$("#"+id).css({
		'margin-left': marginleft,
		'margin-top': marginheight,
		'top': top,
		'left': left
	});

}
//弹框内容
//title 弹框标题
//cont 弹框内容
//iptcont 弹框按钮
//packclass 弹框样式 pack为警告 pack_two为正确
//closeFlag 是否显示关闭按钮

function popcont(title,cont,iptcont,packClass,closeFlag){
	if (title==""||cont==""||iptcont==""||packClass=="") {
		alert('参数错误');
		return;
	}
	var close="<a href=\"javascript:void(0);\" class='close' onclick=\"mask.hide('popStat');$('#popStat').remove()\">close</a>";
	if (closeFlag)
	{
		close='';
	}
	var pophtml = "<style>.alertbox .pack{ padding:30px 15px 0 115px;background: url(/images/common/ico/ts.jpg) no-repeat 30px 16px;}</style><div class=\"alertbox clearfix\" id=\"popStat\" style=\"display:none\"><div class=\"close\"><span>"+title+"</span>"+close+"</div><div class=\""+packClass+" clearfix\">"+cont+iptcont+"</div></div>"
	$("body").append(pophtml);
	mask.show('popStat');
}

